﻿using System;
using System.Collections.Generic; 
using System.Text;
using LandlordOff;

namespace LandlordOffMaster
{
    public  class GameMaster
    {
        private IPlayer[] players;
        private IDealing dealing;
        public GameMaster() { }

        public GameMaster(IPlayer [] _players,IDealing _dealing) 
        {
            players = _players;
            dealing = _dealing;
        }

        public void NewGame()
        { 
            foreach (IPlayer p in players)
                p.Init();
             GameStatus gStatus= dealing.Distribute(players);
             Print(gStatus);
            int first=gStatus .LandlordID ;//地主是第一个下牌的人
            for (int i = first; i < players.Length; i++)
            {
                PlayerStatus pStatus=new PlayerStatus(gStatus,i );
               string cards=  players[i].Play(pStatus);
               gStatus.Update(i,cards);
               Print(gStatus);
            }
        }

        private void Print(GameStatus status)
        {
            Console.WriteLine(status);
        }
    }
}
